<template>
	<view class="container">
		<view class="login">
			<view class="item">
				<view class="label">
					账号
				</view>
                <FrogInput v-model="account" placeholder="请输入您的账号" max="11" type="text"></FrogInput>
			</view>
			<view class="item">
				<view class="label">
					密码
				</view>
                  <FrogInput v-model="password" placeholder="请输入您的密码" type="password"></FrogInput>
			
			</view>
			<view class="item">
				<FrogButton @click="login" type="primary" block>登录</FrogButton>
			</view>
		</view>
	</view>
</template>

<script>
import { login } from '../../api/login';
import { setToken } from '../../utils/auth';
import { hideLoading, showLoading } from '../../utils/message';

	export default {
		data() {
			return {
				account:'15308460183',
				password:''
			}
		},
		methods: {
		 async login(){
				showLoading('登录中')
				const params = {account:this.account,password:this.password};
				const res = await login(params);
				hideLoading();
				if (res.result === 0){
					setToken(res.data.token);
					uni.reLaunch({
						url:'/pages/index/index/index'
					});
				}else{
					uni.showToast({
						title:`${res.message}`,
						icon:'error'
					})
				}
			},
            handleInput(){
                console.log('handleInput');
            },
            handlefocus(){
                 console.log('handlefocus');
            },
            handleBlur(){
                 console.log('handleBlur');
            }
            
		},
       
	}
</script>

<style>
.login{
	margin-top:20px ;
	padding:0 20px;
}

.item{
	margin-top:20px;
	
}

.label{
	padding: 4px 0;
}

</style>
